{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Jeopardy Review\n", "\n", "\n", "\n", "To run the code below, change the file from among [game1.csv](game1.csv), [game2.csv](game2.csv), and [game3.csv](game3.csv).\n", "\n", "Click 6 times to see the categories.\n", "\n", "Team A uses 'w' to buzz in.\n", "\n", "Team B uses 'g' to buzz in.\n", "\n", "Spacebar will go to the next screen. Click again to go back." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " Sketch #1:
\n", "
\n", "
\n", "
\n", " \n", " \n", " \n", " \n", "
\n", "Sketch #1 state: Loading...
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import processing.table.*;\n", "\n", "Table table = loadTable(\"game1.csv\", \"header\");\n", "PFont fontA = loadFont(\"Arial\");\n", "\n", "String[] categories = new String[6];\n", "int score_a = 0;\n", "int score_b = 0;\n", "int reveal = 0;\n", "int[][] boxes = new int[6][5];\n", "String[][] answers = new String[6][5];\n", "String[][] questions = new String[6][5];\n", "int showing_category = -1;\n", "int showing_row = -1;\n", "String pressed = \"\";\n", "\n", "boolean arrayContains(String[] array, String search) {\n", " for (int i = 0; i < array.length; i++) {\n", " if (array[i] == search)\n", " return true;\n", " }\n", " return false;\n", "}\n", "\n", "void setup() {\n", " size(640, 480);\n", " // pick 6 unique categories:\n", " for (int i = 0; i < 6; i++) {\n", " int row_pos = int(random(0, table.getRowCount()));\n", " TableRow row = table.rows().get(row_pos);\n", " String cat = row.getString(\"Category\");\n", " while (arrayContains(categories, cat)) {\n", " row_pos = int(random(0, table.getRowCount()));\n", " row = table.rows().get(row_pos);\n", " cat = row.getString(\"Category\");\n", " }\n", " categories[i] = cat;\n", " // pick one q/a per topic/level:\n", " for (int j = 1; j <= 5; j++) {\n", " ArrayList choices = new ArrayList();\n", " int rows = 0;\n", " for (TableRow trow: table.rows()) {\n", " if (trow.getString(\"Category\") == categories[i] && trow.getInt(\"Level\") == j) {\n", " choices.add(rows);\n", " }\n", " rows++;\n", " }\n", " if (choices.size() == 0) {\n", " println(\"Error in Category: \" + categories[i] + \", level: \" + j + \", count: \" + choices.size());\n", " } else {\n", " // pick one\n", " int pickone = int(random(0, choices.size()));\n", " rows = choices.get(pickone);\n", " answers[i][j - 1] = table.rows().get(rows).getString(\"Answer\");\n", " questions[i][j - 1] = table.rows().get(rows).getString(\"Question\");\n", " }\n", " }\n", " }\n", " // Set up text defaults:\n", " textFont(fontA, 18);\n", " textAlign(CENTER, CENTER);\n", "}\n", "\n", "void draw() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " background(127);\n", " fill(0);\n", " // categories:\n", " rect(5, 5, width - 10, boxh + 10);\n", " // q/a:\n", " rect(5, boxh * 1.5 - 5, width - 10, height - boxh - 70);\n", " // scores:\n", " rect(5, height - 40, width/2 - 10, 35);\n", " rect(width/2 + 5, height - 40, width/2 - 10, 35);\n", " fill(255, 201, 14); // yellow\n", " textAlign(LEFT, CENTER);\n", " text(\"Team A:\", 5, height - 40, width/2 - 10, 35);\n", " text(\"Team B:\", width/2 + 5, height - 40, width/2 - 10, 35);\n", " textAlign(RIGHT, CENTER);\n", " if (score_a >= 0) {\n", " text(\"$\" + score_a, 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_a), 5, height - 40, width/2 - 10, 35);\n", " }\n", " if (score_b >= 0) {\n", " text(\"$\" + score_b, width/2 + 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_b), width/2 + 5, height - 40, width/2 - 10, 35);\n", " }\n", " textAlign(CENTER, CENTER);\n", " // Boxes:\n", " for (int i=0; i < 6; i++) {\n", " fill(63, 72, 204); // blue\n", " rect(i * boxw + 10, 10, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (i < reveal)\n", " text(categories[i], i * boxw + 10, 5, boxw - 10, boxh);\n", " }\n", " for (int x=0; x < 6; x++) {\n", " for (int y=0; y < 5; y++) {\n", " fill(63, 72, 204); // blue\n", " rect(x * boxw + 10, y * (boxh + 10) + boxh * 1.5, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (x < reveal && boxes[x][y] == 0) {\n", " text(\"$\" + ((y + 1) * 100), \n", " x * boxw + 10, y * (boxh + 10) + boxh * 1.5, \n", " boxw - 10, boxh);\n", " }\n", " }\n", " }\n", " if (showing_category >= 0 && showing_row >= 0) {\n", " textAlign(CENTER, CENTER);\n", " fill(63/2, 72/2, 204/2); // blue\n", " rect(50, 50, width - 100, height - 150);\n", " fill(255, 201, 14); // yellow\n", " text(categories[showing_category] + \" for $\" + ((showing_row + 1) * 100), 50, 30, width - 100, 100);\n", " String answer = answers[showing_category][showing_row];\n", " textFont(fontA, 32);\n", " text(answer, 50, 50, width - 100, height - 150);\n", " textFont(fontA, 18);\n", " if (pressed == \"A\") {\n", " text(\"Team A buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"B\") {\n", " text(\"Team B buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"answer\") {\n", " text(questions[showing_category][showing_row], 50, height - 200, width - 100, 100);\n", " }\n", " }\n", "}\n", "\n", "void mousePressed() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " if (reveal < 6) {\n", " reveal++;\n", " } else if (showing_category >= 0 && showing_row >= 0) {\n", " showing_category = -1;\n", " showing_row = -1;\n", " } else {\n", " // playing the game\n", " int category = int((mouseX - 10)/(boxw));\n", " int row = int((mouseY - boxh * 1.5)/(boxh + 10));\n", " //println(\"Category: \" + category + \" row: \" + row);\n", " if (category >= 0 && category < 6) {\n", " if (row >= 0 && row < 5) {\n", " showing_category = category;\n", " showing_row = row;\n", " pressed = \"\";\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", "}\n", "\n", "void keyPressed() {\n", " // w is 87\n", " // a is 65\n", " // s is 83\n", " // d is 68\n", " // f is 70\n", " // g is 71\n", " if (showing_category >= 0 && showing_category < 6) { \n", " if (pressed == \"\") {\n", " if (keyCode == 87) { // w\n", " pressed = \"A\";\n", " } else if (keyCode == 71) { // g\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"A\") {\n", " if (keyCode == 89) { // y correct\n", " score_a += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_a -= (showing_row + 1) * 100;\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"B\") {\n", " if (keyCode == 89) { // y correct\n", " score_b += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_b -= (showing_row + 1) * 100;\n", " pressed = \"A\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"answer\") {\n", " if (keyCode == 32) {\n", " boxes[showing_category][showing_row] = 1;\n", " pressed = \"\";\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", " } \n", "}" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " Sketch #2:
\n", "
\n", "
\n", "
\n", " \n", " \n", " \n", " \n", "
\n", "Sketch #2 state: Loading...
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import processing.table.*;\n", "\n", "Table table = loadTable(\"game2.csv\", \"header\");\n", "PFont fontA = loadFont(\"Arial\");\n", "\n", "String[] categories = new String[6];\n", "int score_a = 0;\n", "int score_b = 0;\n", "int reveal = 0;\n", "int[][] boxes = new int[6][5];\n", "String[][] answers = new String[6][5];\n", "String[][] questions = new String[6][5];\n", "int showing_category = -1;\n", "int showing_row = -1;\n", "String pressed = \"\";\n", "\n", "boolean arrayContains(String[] array, String search) {\n", " for (int i = 0; i < array.length; i++) {\n", " if (array[i] == search)\n", " return true;\n", " }\n", " return false;\n", "}\n", "\n", "void setup() {\n", " size(640, 480);\n", " // pick 6 unique categories:\n", " for (int i = 0; i < 6; i++) {\n", " int row_pos = int(random(0, table.getRowCount()));\n", " TableRow row = table.rows().get(row_pos);\n", " String cat = row.getString(\"Category\");\n", " while (arrayContains(categories, cat)) {\n", " row_pos = int(random(0, table.getRowCount()));\n", " row = table.rows().get(row_pos);\n", " cat = row.getString(\"Category\");\n", " }\n", " categories[i] = cat;\n", " // pick one q/a per topic/level:\n", " for (int j = 1; j <= 5; j++) {\n", " ArrayList choices = new ArrayList();\n", " int rows = 0;\n", " for (TableRow trow: table.rows()) {\n", " if (trow.getString(\"Category\") == categories[i] && trow.getInt(\"Level\") == j) {\n", " choices.add(rows);\n", " }\n", " rows++;\n", " }\n", " if (choices.size() == 0) {\n", " println(\"Error in Category: \" + categories[i] + \", level: \" + j + \", count: \" + choices.size());\n", " } else {\n", " // pick one\n", " int pickone = int(random(0, choices.size()));\n", " rows = choices.get(pickone);\n", " answers[i][j - 1] = table.rows().get(rows).getString(\"Answer\");\n", " questions[i][j - 1] = table.rows().get(rows).getString(\"Question\");\n", " }\n", " }\n", " }\n", " // Set up text defaults:\n", " textFont(fontA, 18);\n", " textAlign(CENTER, CENTER);\n", "}\n", "\n", "void draw() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " background(127);\n", " fill(0);\n", " // categories:\n", " rect(5, 5, width - 10, boxh + 10);\n", " // q/a:\n", " rect(5, boxh * 1.5 - 5, width - 10, height - boxh - 70);\n", " // scores:\n", " rect(5, height - 40, width/2 - 10, 35);\n", " rect(width/2 + 5, height - 40, width/2 - 10, 35);\n", " fill(255, 201, 14); // yellow\n", " textAlign(LEFT, CENTER);\n", " text(\"Team A:\", 5, height - 40, width/2 - 10, 35);\n", " text(\"Team B:\", width/2 + 5, height - 40, width/2 - 10, 35);\n", " textAlign(RIGHT, CENTER);\n", " if (score_a >= 0) {\n", " text(\"$\" + score_a, 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_a), 5, height - 40, width/2 - 10, 35);\n", " }\n", " if (score_b >= 0) {\n", " text(\"$\" + score_b, width/2 + 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_b), width/2 + 5, height - 40, width/2 - 10, 35);\n", " }\n", " textAlign(CENTER, CENTER);\n", " // Boxes:\n", " for (int i=0; i < 6; i++) {\n", " fill(63, 72, 204); // blue\n", " rect(i * boxw + 10, 10, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (i < reveal)\n", " text(categories[i], i * boxw + 10, 5, boxw - 10, boxh);\n", " }\n", " for (int x=0; x < 6; x++) {\n", " for (int y=0; y < 5; y++) {\n", " fill(63, 72, 204); // blue\n", " rect(x * boxw + 10, y * (boxh + 10) + boxh * 1.5, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (x < reveal && boxes[x][y] == 0) {\n", " text(\"$\" + ((y + 1) * 100), \n", " x * boxw + 10, y * (boxh + 10) + boxh * 1.5, \n", " boxw - 10, boxh);\n", " }\n", " }\n", " }\n", " if (showing_category >= 0 && showing_row >= 0) {\n", " textAlign(CENTER, CENTER);\n", " fill(63/2, 72/2, 204/2); // blue\n", " rect(50, 50, width - 100, height - 150);\n", " fill(255, 201, 14); // yellow\n", " text(categories[showing_category] + \" for $\" + ((showing_row + 1) * 100), 50, 30, width - 100, 100);\n", " String answer = answers[showing_category][showing_row];\n", " textFont(fontA, 32);\n", " text(answer, 50, 50, width - 100, height - 150);\n", " textFont(fontA, 18);\n", " if (pressed == \"A\") {\n", " text(\"Team A buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"B\") {\n", " text(\"Team B buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"answer\") {\n", " text(questions[showing_category][showing_row], 50, height - 200, width - 100, 100);\n", " }\n", " }\n", "}\n", "\n", "void mousePressed() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " if (reveal < 6) {\n", " reveal++;\n", " } else if (showing_category >= 0 && showing_row >= 0) {\n", " showing_category = -1;\n", " showing_row = -1;\n", " } else {\n", " // playing the game\n", " int category = int((mouseX - 10)/(boxw));\n", " int row = int((mouseY - boxh * 1.5)/(boxh + 10));\n", " //println(\"Category: \" + category + \" row: \" + row);\n", " if (category >= 0 && category < 6) {\n", " if (row >= 0 && row < 5) {\n", " showing_category = category;\n", " showing_row = row;\n", " pressed = \"\";\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", "}\n", "\n", "void keyPressed() {\n", " // w is 87\n", " // a is 65\n", " // s is 83\n", " // d is 68\n", " // f is 70\n", " // g is 71\n", " if (showing_category >= 0 && showing_category < 6) { \n", " if (pressed == \"\") {\n", " if (keyCode == 87) { // w\n", " pressed = \"A\";\n", " } else if (keyCode == 71) { // g\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"A\") {\n", " if (keyCode == 89) { // y correct\n", " score_a += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_a -= (showing_row + 1) * 100;\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"B\") {\n", " if (keyCode == 89) { // y correct\n", " score_b += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_b -= (showing_row + 1) * 100;\n", " pressed = \"A\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"answer\") {\n", " if (keyCode == 32) {\n", " boxes[showing_category][showing_row] = 1;\n", " pressed = \"\";\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", " } \n", "}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " Sketch #3:
\n", "
\n", "
\n", "
\n", " \n", " \n", " \n", " \n", "
\n", "Sketch #3 state: Loading...
\n", "\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import processing.table.*;\n", "\n", "Table table = loadTable(\"game3.csv\", \"header\");\n", "PFont fontA = loadFont(\"Arial\");\n", "\n", "String[] categories = new String[6];\n", "int score_a = 0;\n", "int score_b = 0;\n", "int reveal = 0;\n", "int[][] boxes = new int[6][5];\n", "String[][] answers = new String[6][5];\n", "String[][] questions = new String[6][5];\n", "int showing_category = -1;\n", "int showing_row = -1;\n", "String pressed = \"\";\n", "\n", "boolean arrayContains(String[] array, String search) {\n", " for (int i = 0; i < array.length; i++) {\n", " if (array[i] == search)\n", " return true;\n", " }\n", " return false;\n", "}\n", "\n", "void setup() {\n", " size(640, 480);\n", " // pick 6 unique categories:\n", " for (int i = 0; i < 6; i++) {\n", " int row_pos = int(random(0, table.getRowCount()));\n", " TableRow row = table.rows().get(row_pos);\n", " String cat = row.getString(\"Category\");\n", " while (arrayContains(categories, cat)) {\n", " row_pos = int(random(0, table.getRowCount()));\n", " row = table.rows().get(row_pos);\n", " cat = row.getString(\"Category\");\n", " }\n", " categories[i] = cat;\n", " // pick one q/a per topic/level:\n", " for (int j = 1; j <= 5; j++) {\n", " ArrayList choices = new ArrayList();\n", " int rows = 0;\n", " for (TableRow trow: table.rows()) {\n", " if (trow.getString(\"Category\") == categories[i] && trow.getInt(\"Level\") == j) {\n", " choices.add(rows);\n", " }\n", " rows++;\n", " }\n", " if (choices.size() == 0) {\n", " println(\"Error in Category: \" + categories[i] + \", level: \" + j + \", count: \" + choices.size());\n", " } else {\n", " // pick one\n", " int pickone = int(random(0, choices.size()));\n", " rows = choices.get(pickone);\n", " answers[i][j - 1] = table.rows().get(rows).getString(\"Answer\");\n", " questions[i][j - 1] = table.rows().get(rows).getString(\"Question\");\n", " }\n", " }\n", " }\n", " // Set up text defaults:\n", " textFont(fontA, 18);\n", " textAlign(CENTER, CENTER);\n", "}\n", "\n", "void draw() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " background(127);\n", " fill(0);\n", " // categories:\n", " rect(5, 5, width - 10, boxh + 10);\n", " // q/a:\n", " rect(5, boxh * 1.5 - 5, width - 10, height - boxh - 70);\n", " // scores:\n", " rect(5, height - 40, width/2 - 10, 35);\n", " rect(width/2 + 5, height - 40, width/2 - 10, 35);\n", " fill(255, 201, 14); // yellow\n", " textAlign(LEFT, CENTER);\n", " text(\"Team A:\", 5, height - 40, width/2 - 10, 35);\n", " text(\"Team B:\", width/2 + 5, height - 40, width/2 - 10, 35);\n", " textAlign(RIGHT, CENTER);\n", " if (score_a >= 0) {\n", " text(\"$\" + score_a, 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_a), 5, height - 40, width/2 - 10, 35);\n", " }\n", " if (score_b >= 0) {\n", " text(\"$\" + score_b, width/2 + 5, height - 40, width/2 - 10, 35);\n", " } else {\n", " text(\"-$\" + (-score_b), width/2 + 5, height - 40, width/2 - 10, 35);\n", " }\n", " textAlign(CENTER, CENTER);\n", " // Boxes:\n", " for (int i=0; i < 6; i++) {\n", " fill(63, 72, 204); // blue\n", " rect(i * boxw + 10, 10, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (i < reveal)\n", " text(categories[i], i * boxw + 10, 5, boxw - 10, boxh);\n", " }\n", " for (int x=0; x < 6; x++) {\n", " for (int y=0; y < 5; y++) {\n", " fill(63, 72, 204); // blue\n", " rect(x * boxw + 10, y * (boxh + 10) + boxh * 1.5, boxw - 10, boxh);\n", " fill(255, 201, 14); // yellow\n", " if (x < reveal && boxes[x][y] == 0) {\n", " text(\"$\" + ((y + 1) * 100), \n", " x * boxw + 10, y * (boxh + 10) + boxh * 1.5, \n", " boxw - 10, boxh);\n", " }\n", " }\n", " }\n", " if (showing_category >= 0 && showing_row >= 0) {\n", " textAlign(CENTER, CENTER);\n", " fill(63/2, 72/2, 204/2); // blue\n", " rect(50, 50, width - 100, height - 150);\n", " fill(255, 201, 14); // yellow\n", " text(categories[showing_category] + \" for $\" + ((showing_row + 1) * 100), 50, 30, width - 100, 100);\n", " String answer = answers[showing_category][showing_row];\n", " textFont(fontA, 32);\n", " text(answer, 50, 50, width - 100, height - 150);\n", " textFont(fontA, 18);\n", " if (pressed == \"A\") {\n", " text(\"Team A buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"B\") {\n", " text(\"Team B buzzes in! Correct? y/n\", 50, height - 200, width - 100, 100);\n", " } else if (pressed == \"answer\") {\n", " text(questions[showing_category][showing_row], 50, height - 200, width - 100, 100);\n", " }\n", " }\n", "}\n", "\n", "void mousePressed() {\n", " int boxw = width/6.1;\n", " int boxh= height/8;\n", " if (reveal < 6) {\n", " reveal++;\n", " } else if (showing_category >= 0 && showing_row >= 0) {\n", " showing_category = -1;\n", " showing_row = -1;\n", " } else {\n", " // playing the game\n", " int category = int((mouseX - 10)/(boxw));\n", " int row = int((mouseY - boxh * 1.5)/(boxh + 10));\n", " //println(\"Category: \" + category + \" row: \" + row);\n", " if (category >= 0 && category < 6) {\n", " if (row >= 0 && row < 5) {\n", " showing_category = category;\n", " showing_row = row;\n", " pressed = \"\";\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " } else {\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", "}\n", "\n", "void keyPressed() {\n", " // w is 87\n", " // a is 65\n", " // s is 83\n", " // d is 68\n", " // f is 70\n", " // g is 71\n", " if (showing_category >= 0 && showing_category < 6) { \n", " if (pressed == \"\") {\n", " if (keyCode == 87) { // w\n", " pressed = \"A\";\n", " } else if (keyCode == 71) { // g\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"A\") {\n", " if (keyCode == 89) { // y correct\n", " score_a += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_a -= (showing_row + 1) * 100;\n", " pressed = \"B\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"B\") {\n", " if (keyCode == 89) { // y correct\n", " score_b += (showing_row + 1) * 100;\n", " pressed = \"answer\";\n", " } else if (keyCode == 78) { // n wrong\n", " score_b -= (showing_row + 1) * 100;\n", " pressed = \"A\";\n", " } else if (keyCode == 32) {\n", " pressed = \"answer\";\n", " }\n", " } else if (pressed == \"answer\") {\n", " if (keyCode == 32) {\n", " boxes[showing_category][showing_row] = 1;\n", " pressed = \"\";\n", " showing_category = -1;\n", " showing_row = -1;\n", " }\n", " }\n", " } \n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Calysto Processing", "language": "processing", "name": "calysto_processing" }, "language_info": { "codemirror_mode": { "name": "text/x-java", "version": 2 }, "file_extension": ".java", "mimetype": "text/x-java", "name": "java" } }, "nbformat": 4, "nbformat_minor": 0 }